/**
 * Created by ztt on 2018/12/3.
 */
import {Observable} from 'rxjs';
const obs:Observable<number>=Observable.create(function (observer:any) {
    observer.next(1);
    observer.next(2);
    observer.next(3);
    setTimeout(() => {
        observer.next(4);
        observer.complete();
    }, 1000);
});

console.log('just before subscribe');
obs.subscribe({
    next: x => console.log('got value ' + x),
    error: err => console.error('something wrong occurred: ' + err),
    complete: () => console.log('done'),
});
console.log('just after subscribe');

const obs2:Observable<number>=Observable.create((observer:any) => {
    observer.next(1);
    observer.next(2);
    observer.complete();
});
obs2.subscribe({
    next: x => console.log('obs2 => got value ' + x),
    error: err => console.error('obs2 => something wrong occurred: ' + err),
    complete: () => console.log('obs2 => done'),
});
